package com.bblocks.enums;

import com.bblocks.config.SwaggerDisplayEnum;
import com.bblocks.exception.ServiceException;
import lombok.Getter;

/**
 * 交易相关的(只限交易的)
 * select * from t_dict d where d.`dict_cate_id`=1
 */
@Getter
@SwaggerDisplayEnum(index = "code", name = "name")
public enum ProfessionCodeTradEnum {
	CommTrad(1149, "通用服务"),
	MallTrad(1161, "电商服务"),
	SecondHouseTrad(1, "二手房服务"),
	BuildingTrad(4, "写字楼"),

	NewHouse(990, "新房"),
	//SecondHouseTrad(5, "产业园"),
	;

	Integer code;
	String name;

	ProfessionCodeTradEnum(Integer code, String name) {
		this.code = code;
		this.name = name;
	}

	private static ProfessionCodeTradEnum[] values = ProfessionCodeTradEnum.values();
	public static ProfessionCodeTradEnum getByCode(Integer code) {
		if(values == null)
			return null;
		for (ProfessionCodeTradEnum c : values) {
			if (c.getCode().equals(code) ) {
				return c;
			}
		}

		throw new ServiceException("无此类型："+code);
	}
}
